package WWW.SST.LIB;

import java.util.*;

/** 
 Common ��ժҪ˵����
*/
public class Common
{
	public Common()
	{

	}
	public final boolean IsPassed(ArrayList ComeinArr)
	{
		for (String Comein : ComeinArr)
		{
			if (!Come(Comein))
			{
				return false;
			}
		}
		return true;
	}
	private boolean Come(String Comein)
	{
		int come = Integer.parseInt(Comein.replace("-",""));
		int now = Integer.parseInt(showQishu().replace("-",""));
		if (come == now - 1)
		{
			if (java.time.LocalDateTime.now().getMinute() % 10 == 8 && java.time.LocalDateTime.now().getSecond() < 30)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		if (come <= now - 2)
		{
			return false;
		}
		if (java.time.LocalDateTime.now().getHour() >= 22 && java.time.LocalDateTime.now().getMinute() >= 48)
		{
			String year = java.time.LocalDateTime.now().getYear().toString();
			String month = java.time.LocalDateTime.now().getMonthValue().toString().length() == 2?java.time.LocalDateTime.now().getMonthValue().toString():"0" + java.time.LocalDateTime.now().getMonthValue().toString();
			String day = java.time.LocalDateTime.now().getDayOfMonth().toString().length() == 2?java.time.LocalDateTime.now().getDayOfMonth().toString():"0" + java.time.LocalDateTime.now().getDayOfMonth().toString();
			String temp = year + month + day + "-72";
			if (Comein.equals(temp))
			{
				return false;
			}
		}
		return true;
	}



	private String showQishu()
	{
		String year = java.time.LocalDateTime.now().getYear().toString();
		String month = java.time.LocalDateTime.now().getMonthValue().toString().length() == 2?java.time.LocalDateTime.now().getMonthValue().toString():"0" + java.time.LocalDateTime.now().getMonthValue().toString();
		String day = java.time.LocalDateTime.now().getDayOfMonth().toString().length() == 2?java.time.LocalDateTime.now().getDayOfMonth().toString():"0" + java.time.LocalDateTime.now().getDayOfMonth().toString();
		String hour = java.time.LocalDateTime.now().getHour().toString().length() == 2?java.time.LocalDateTime.now().getHour().toString():"0" + java.time.LocalDateTime.now().getHour().toString();
		String minute = java.time.LocalDateTime.now().getMinute().toString();
		String reasult = "";
		TimeSpan spBegin = new TimeSpan(10,48,0);
		TimeSpan spEnd = new TimeSpan(22,48,0);
		/*
		TimeSpan spBegin = new TimeSpan (9,48,0);
		TimeSpan spEnd = new TimeSpan (21,48,0);
		
		*/

		TimeSpan now = new TimeSpan(java.time.LocalDateTime.now().getHour(),java.time.LocalDateTime.now().getMinute(),0);
		if (now < spBegin || now >= spEnd)
		{

			return "0";
		}
		//����ڿ�ʼʱ�� �� ��ʼʱ�䣫10���� �� �����һ�� ��Ϊ���� ��һ�ڵ���д
		if (now >= spBegin && now < spBegin.Add(new TimeSpan(0,10,0)))
		{

			return year + month + day + "-" + "01";

		}
		reasult += year + month + day;
		int qishu = 0;
		tangible.RefObject<Integer> tempRef_qishu = new tangible.RefObject<Integer>(qishu);
		getQishu(tempRef_qishu);
		qishu = tempRef_qishu.argValue;
		String qishustr = "";
		if (String.valueOf(qishu).length() == 1)
		{
			qishustr = "0" + qishu;
			reasult += "-" + qishustr;
		}
		else
		{
			reasult += "-" + String.valueOf(qishu);
		}
		return reasult;
	}
	private void getQishu(tangible.RefObject<Integer> x)
	{
		int hour = java.time.LocalDateTime.now().getHour();
		int minute = java.time.LocalDateTime.now().getMinute();
		if (10 <= hour && hour < 11)
		{
			x.argValue = 2;
		}
		if (11 <= hour && hour < 12)
		{
			x.argValue = gettime(0);
		}
		if (12 <= hour && hour < 13)
		{
			x.argValue = gettime(1);
		}
		if (13 <= hour && hour < 14)
		{
			x.argValue = gettime(2);
		}
		if (14 <= hour && hour < 15)
		{
			x.argValue = gettime(3);
		}
		if (15 <= hour && hour < 16)
		{
			x.argValue = gettime(4);
		}
		if (16 <= hour && hour < 17)
		{
			x.argValue = gettime(5);
		}
		if (17 <= hour && hour < 18)
		{
			x.argValue = gettime(6);
		}
		if (18 <= hour && hour < 19)
		{
			x.argValue = gettime(7);
		}
		if (19 <= hour && hour < 20)
		{
			x.argValue = gettime(8);
		}
		if (20 <= hour && hour < 21)
		{
			x.argValue = gettime(9);
		}
		if (21 <= hour && hour < 22)
		{
			x.argValue = gettime(10);
		}
		if (22 <= hour && hour < 23)
		{
			x.argValue = gettime(11);
		}
		return;
	}

	private int gettime(int i)
	{
		int minute = java.time.LocalDateTime.now().getMinute();
		int time = 0;
		if (0 <= minute && minute < 8)
		{
			time = 2 + i * 6;
		}
		else if (8 <= minute && minute < 18)
		{
			time = 3 + i * 6;
		}
		else if (18 <= minute && minute < 28)
		{
			time = 4 + i * 6;
		}
		else if (28 <= minute && minute < 38)
		{
			time = 5 + i * 6;
		}
		else if (38 <= minute && minute < 48)
		{
			time = 6 + i * 6;
		}
		else if (48 <= minute && minute < 58)
		{
			time = 7 + i * 6;
		}
		else
		{
			time = 8 + i * 6;
		}
		return time;
	}

}